module.exports = {
  description: "query列表查询页面",
  prompts: [
    {
      type: "input",
      name: "name",
      message: "query name please",
      validate: (v) => {
        return !v || v.trim() === "" ? `${name} is required` : true;
      },
    },
  ],
  actions: (data) => {
    const name = "{{name}}";
    const actions = [
      {
        type: "add",
        path: `apps/resource/${name}/index.html`,
        templateFile: "plop-templates/query/index.hbs",
        force: true,
        data: {
          name
        },
      },
      {
        type: "add",
        path: `apps/resource/${name}/form.html`,
        templateFile: "plop-templates/query/form.hbs",
        force: true,
        data: {
          name
        },
      },
      {
        type: "add",
        path: `apps/resource/${name}/js/index.js`,
        templateFile: "plop-templates/query/js/index.hbs",
        force: true,
        data: {
          name
        },
      },
      {
        type: "add",
        path: `apps/resource/${name}/js/form.js`,
        templateFile: "plop-templates/query/js/form.hbs",
        force: true,
        data: {
          name
        },
      },
      {
        type: "append",
        path: 'apps/init.js',
        pattern: 'resources: [',
        template: `          '${name}',`
      }
    ]
    return actions;
  },
}